cmake_minimum_required(VERSION 3.5.1)
project(videoDecodeGdr)
MESSAGE(${CMAKE_HOST_SYSTEM_PROCESSOR})
set(CMAKE_CXX_STANDARD 11)

if(DEFINED ENV{LYNXI_CROSS_COMPILE})
    set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")
    include_directories(/usr/local/lynxi/cross_compile/include)
    link_directories(/usr/local/lynxi/cross_compile/libs)
else()
    set(CMAKE_CXX_COMPILER "g++")
endif()

include_directories(${PROJECT_SOURCE_DIR}/../../../common/cpp)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../../../bin)

# opencv
find_package(PkgConfig REQUIRED)
pkg_check_modules(OPENCV opencv)
if(OPENCV_FOUND)
    include_directories(${OPENCV_INCLUDE_DIRS})
    link_directories(${OPENCV_LIBRARY_DIRS})
    link_libraries(${OPENCV_LIBRARIES})
    add_compile_options(${OPENCV_CFLAGS_OTHER})
    MESSAGE("opencv include folder: " ${OPENCV_INCLUDE_DIRS})
    MESSAGE("opencv lib folder: " ${OPENCV_LIBRARY_DIRS})
    MESSAGE("opencv libs: " ${OPENCV_LIBRARIES})
    MESSAGE("opencv flags other: " ${OPENCV_CFLAGS_OTHER})
    add_definitions(-DHAVE_OPENCV)
else()
    pkg_check_modules(OPENCV4 opencv4)
    if(OPENCV4_FOUND)
        include_directories(${OPENCV4_INCLUDE_DIRS})
        link_directories(${OPENCV4_LIBRARY_DIRS})
        link_libraries(${OPENCV4_LIBRARIES})
        add_compile_options(${OPENCV4_CFLAGS_OTHER})
        MESSAGE("opencv4 include folder: " ${OPENCV4_INCLUDE_DIRS})
        MESSAGE("opencv4 lib folder: " ${OPENCV4_LIBRARY_DIRS})
        MESSAGE("opencv4 libs: " ${OPENCV4_LIBRARIES})
        MESSAGE("opencv4 flags other: " ${OPENCV4_CFLAGS_OTHER})
        add_definitions(-DHAVE_OPENCV)
    else(OPENCV4_FOUND)
        MESSAGE("Don't have opencv, You can install opencv!")
    endif(OPENCV4_FOUND)
endif(OPENCV_FOUND)

link_libraries(-lLYNCHIPSDKCLIENT -lLYNCHIPSDKCLIENTCOMM -lLYNSMICLIENTCOMM -lpthread)

add_executable(videoDecodeGdr main.cpp)